import template from '@/utils/dyMode';
import {onMounted, ref,  reactive, computed } from 'vue';
import { hiprint, defaultElementTypeProvider } from"vue-plugin-hiprint";
export default function importConfig(props) {
    const base = reactive<any>({
        visible: false,
        spinning: true,
        jsonOut: "",
        tidMode: false,
        beautify: false,
        template: ''
    })
    
    const hideModal = () => {
        base.visible = false
    }


    const show = () => {
        base.template = props.template;
        base.visible = true
        base.spinning = true
        setTimeout(() => {
            let json = base.tidMode ? base.template.getJsonTid() : base.template.getJson();
            let beautify = base.beautify ? 2 : 0;
            base.jsonOut = JSON.stringify(json, null, beautify);
            console.log(base.template.getJson());
            base.spinning = false
        }, 500)
    }

    const onModeChange = () => {
        show(); 
    }

    return {
        base,
        hideModal,
        show,
        onModeChange,

    }
}